package com.yangqi.net;

import java.io.*;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

public class ClientClass {

    public static void main(String[] args)throws IOException {
        Socket socket = new Socket(InetAddress.getLocalHost(), 9999);

        OutputStream bos = socket.getOutputStream();
        bos.write("我要连接啦".getBytes());
        //写入结束标记
        socket.shutdownOutput();

        InputStream bis = socket.getInputStream();
        byte[] bytes = new byte[1024];
        int len = 0;
        while((len = bis.read(bytes)) != -1){
            System.out.println(new String(bytes,0,len));
        }

        bos.close();
        socket.close();
    }

}
